home *** CD-ROM | disk | FTP | other *** search
/ Champak 43 / Vol 43.iso / games / phit.swf / scripts / __Packages / CLineSegment.as < prev    next >
Encoding:
Text File  |  2007-07-13  |  1.2 KB  |  43 lines

  1. class CLineSegment extends CCollisionVolume
  2. {
  3.    var m_endpoint1;
  4.    var m_endpoint2;
  5.    var m_body;
  6.    var m_radius = 0;
  7.    function CLineSegment(body)
  8.    {
  9.       super(body);
  10.       this.m_endpoint1 = new Vector2D(0,0);
  11.       this.m_endpoint2 = new Vector2D(0,0);
  12.    }
  13.    function UpdateToBodyMotion()
  14.    {
  15.       this.m_endpoint1 = this.m_body._location;
  16.       this.m_endpoint2 = this.m_body._lastLocation;
  17.    }
  18.    function get _length()
  19.    {
  20.       return this.m_endpoint1.GetDistance(this.m_endpoint2);
  21.    }
  22.    function get _radius()
  23.    {
  24.       return this.m_radius;
  25.    }
  26.    function set _radius(radius)
  27.    {
  28.       this.m_radius = radius;
  29.    }
  30.    function get _topLeftCorner()
  31.    {
  32.       return new Vector2D(Math.min(this.m_endpoint1._x - this.m_radius,this.m_endpoint2._x - this.m_radius),Math.min(this.m_endpoint1._y - this.m_radius,this.m_endpoint2._y - this.m_radius));
  33.    }
  34.    function get _bottomRightCorner()
  35.    {
  36.       return new Vector2D(Math.max(this.m_endpoint1._x + this.m_radius,this.m_endpoint2._x + this.m_radius),Math.max(this.m_endpoint1._y + this.m_radius,this.m_endpoint2._y + this.m_radius));
  37.    }
  38.    function MayCollideOnSeparation()
  39.    {
  40.       return true;
  41.    }
  42. }
  43.